package com.shop;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.SimpleAdapter;
import android.widget.Toast;

import com.shop.adapter.MySimpleAdapter;
import com.shop.inteface.FragmentDelegate;
import com.shop.third.DividerItemDecoration;

import java.util.ArrayList;
import java.util.List;

public class MomentFragment extends Fragment {
    private FragmentDelegate mListener;

    private RecyclerView mRecyclerView;
    private List<String> mDatas;
    private MySimpleAdapter mAdapter;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
        super.onCreateView(inflater, container, savedInstanceState);
        View chatView = inflater.inflate(R.layout.fragment_moment, container,false);

        mRecyclerView= (RecyclerView) chatView.findViewById(R.id.id_recyclerView);
        mDatas =new ArrayList<String>();
        for (int i='A';i<='z';i++){
            mDatas.add(""+(char)i);
        }
        mAdapter=new MySimpleAdapter(this.getContext(),mDatas);
        mRecyclerView.setAdapter(mAdapter);

        //设置RecyclerView的布局管理
        LinearLayoutManager linearLayoutManager=new LinearLayoutManager(this.getContext(),LinearLayoutManager.VERTICAL,false);
        mRecyclerView.setLayoutManager(linearLayoutManager);

        mAdapter.setmOnItemClickListener(new MySimpleAdapter.OnItemClickListener() {
            @Override
            public void OnItemClick(View view, int position) {

            }
        });

        //设置RecyclerView的Item间的分割线
        mRecyclerView.addItemDecoration(new DividerItemDecoration(this.getContext(),DividerItemDecoration.VERTICAL_LIST));

        return chatView;


    }




    @Override
    public void onActivityCreated(Bundle savedInstanceState){
        super.onActivityCreated(savedInstanceState);
    }
}
